package com.ruoyi.matchmaker.controller;

import java.util.List;
import javax.servlet.http.HttpServletResponse;

import com.ruoyi.matchmaker.domain.TbMatchmaker;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.matchmaker.service.ITbMatchmakerService;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.common.core.page.TableDataInfo;

/**
 * 红娘信息Controller
 *
 * @author ruoyi
 * @date 2025-07-29
 */
@RestController
@RequestMapping("/matchmaker/matchmaker")
public class TbMatchmakerController extends BaseController
{
    @Autowired
    private ITbMatchmakerService tbMatchmakerService;

    /**
     * 查询红娘信息列表
     */
    @PreAuthorize("@ss.hasPermi('matchmaker:matchmakers:list')")
    @GetMapping("/list")
    public TableDataInfo list(TbMatchmaker tbMatchmaker)
    {
        startPage();
        List<TbMatchmaker> list = tbMatchmakerService.selectTbMatchmakerList(tbMatchmaker);
        return getDataTable(list);
    }

    /**
     * 导出红娘信息列表
     */
    @PreAuthorize("@ss.hasPermi('matchmaker:matchmakers:export')")
    @Log(title = "红娘信息", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, TbMatchmaker tbMatchmaker)
    {
        List<TbMatchmaker> list = tbMatchmakerService.selectTbMatchmakerList(tbMatchmaker);
        ExcelUtil<TbMatchmaker> util = new ExcelUtil<TbMatchmaker>(TbMatchmaker.class);
        util.exportExcel(response, list, "红娘信息数据");
    }

    /**
     * 获取红娘信息详细信息
     */
    @PreAuthorize("@ss.hasPermi('matchmaker:matchmakers:query')")
    @GetMapping(value = "/{matchmakerId}")
    public AjaxResult getInfo(@PathVariable("matchmakerId") Long matchmakerId)
    {
        return success(tbMatchmakerService.selectTbMatchmakerByMatchmakerId(matchmakerId));
    }

    /**
     * 新增红娘信息
     */
    @PreAuthorize("@ss.hasPermi('matchmaker:matchmakers:add')")
    @Log(title = "红娘信息", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody TbMatchmaker tbMatchmaker)
    {
        return toAjax(tbMatchmakerService.insertTbMatchmaker(tbMatchmaker));
    }

    /**
     * 修改红娘信息
     */
    @PreAuthorize("@ss.hasPermi('matchmaker:matchmakers:edit')")
    @Log(title = "红娘信息", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody TbMatchmaker tbMatchmaker)
    {
        return toAjax(tbMatchmakerService.updateTbMatchmaker(tbMatchmaker));
    }

    /**
     * 删除红娘信息
     */
    @PreAuthorize("@ss.hasPermi('matchmaker:matchmakers:remove')")
    @Log(title = "红娘信息", businessType = BusinessType.DELETE)
	@DeleteMapping("/{matchmakerIds}")
    public AjaxResult remove(@PathVariable Long[] matchmakerIds)
    {
        return toAjax(tbMatchmakerService.deleteTbMatchmakerByMatchmakerIds(matchmakerIds));
    }
}